<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:p="http://primefaces.prime.com.tr/ui">

<ui:composition template="_empenho.xhtml">
	<ui:define name="corpo"><br />

		<div id="conteudo">

			<h:form id="form">

				<h2>
					<h:outputText value="EDITAR EMPENHO"/>
				</h2>
				<hr /><br />

				<p:messages id="msg" />
				
				<div align="left">
				<p:fieldset legend="Pesquisar">
				
				<h:outputLink value="javascript:void(0)" onclick="dlgeEmp.show();">
					<h:outputLabel value="Pesquisar: " rendered="#{empty empenhoBean.empenho.id}" />
					<h:outputLabel value="Empenho: " rendered="#{not empty empenhoBean.empenho.id}" />
				</h:outputLink>
				
				<h:outputLink value="javascript:void(0)" onclick="dlgeEmp.show();">
				<h:graphicImage value="resources/img/lupa5.png" style="width: 40px;" onclick="dlgEmp.show();" rendered="#{empty empenhoBean.empenho.id}" />
					<h:outputText id="nf" value="#{empenhoBean.empenho.numero}" onclick="dlgEmp.show();" style="text-align: center; float: center; font-weight:bold;" 
						rendered="#{not empty empenhoBean.empenho.id}" />
				</h:outputLink>		
				
				</p:fieldset>
				</div>
				
				<p:fieldset>
				<h:panelGrid columns="3">
				
				<h:outputLabel value="Credor: " for="credor" />
				<h:outputText id="credor" value="#{empenhoBean.empenho.fornecedor.nome}" /><br /><br />
				
				<h:outputLabel value="Interessado: " for="interessado" />
				<h:outputText id="interessado" value="#{empenhoBean.empenho.interessado}"/><br /><br />
				
				<h:outputLabel value="Data de Emissão: " />
				<h:outputText value="" rendered="#{empty empenhoBean.empenho.id}" />
				<h:outputText value="#{empenhoBean.empenho.data.time}" rendered="#{not empty empenhoBean.empenho.id}">
					<f:convertDateTime pattern="dd/MM/yyyy" timeZone="America/Sao_Paulo" />
				</h:outputText><br /><br />
							
				<h:outputLabel value="Valor Total: " for="valor" />
				<h:outputText id="valor" value="#{empenhoBean.empenho.valor_total}" disabled="true">
					<f:convertNumber pattern="#,##0.00" />
				</h:outputText>	<br /><br />

				<h:outputLabel value="Processo: " for="proc"  />
				<h:outputText id="proc" value="#{empenhoBean.empenho.processo}" />
				<br /><br />
				
				<h:outputLabel value="Tipo: " for="tipo" />
				<h:selectOneMenu id="tipo" value="#{empenhoBean.empenho.tipo}" disabled="true">
					<f:selectItem itemLabel="" noSelectionOption="true" ></f:selectItem>
					<f:selectItem itemLabel="Ordinário" itemValue="Ordinário" />
					<f:selectItem itemLabel="Global" itemValue="Global" />
					<f:selectItem itemLabel="Estimativo" itemValue="Estimativo" />
				</h:selectOneMenu><br /><br />
				
				<h:outputLabel value="Status: " for="status" />
				<h:selectOneMenu id="status" value="#{empenhoBean.empenho.status}" disabled="true">
					<f:selectItem itemLabel="" noSelectionOption="true" ></f:selectItem>
					<f:selectItem itemLabel="Executado" itemValue="Executado" />
					<f:selectItem itemLabel="Entrega Parcial" itemValue="Entrega Parcial" />
					<f:selectItem itemLabel="Aguardando Entrega" itemValue="Aguardando Entrega" />
				</h:selectOneMenu><br /><br />	
				
				<h:outputLabel value="Receber Empenho: " for="receber" style="color: red;" />
				<h:selectOneRadio id="receber" value="#{empenhoBean.empenho.status}" required="true" requiredMessage="Marque a Caixa Para Receber o Empenho ou Cancele Para Sair">
					<f:selectItem itemLabel="Executado" itemValue="Executado" />
				</h:selectOneRadio><br /><br />			

				<p:commandButton id="grava" value="RECEBER EMPENHO" action="#{empenhoBean.recebido}" ajax="false" image="ui-icon-disk" rendered="#{not empty empenhoBean.empenho.id}">
					<f:ajax render="@all" />
				</p:commandButton>	

				
				<p:commandButton id="cancel" value="CANCELAR RECEBIMENTO" action="formAlterEmpenho.xhtml"
						rendered="#{not empty empenhoBean.empenho.id}" ajax="false" icon="ui-icon-arrowreturnthick-1-w">
						<f:ajax render="@all" />
					</p:commandButton>
				<p />
				
				</h:panelGrid>
				</p:fieldset>				

			</h:form>
			
			<p:dialog header="Empenhos Cadastradas" widgetVar="dlgEmp" width="500">
					<h:form id="form1">

						<p:outputPanel id="emps">
							<p:dataTable value="#{empenhoBean.empenhos}" var="empenho" paginator="true"
								rows="10" emptyMessage="Não Encontrado">

								<p:column filterBy="#{empenho.numero}" filterMatchMode="contains"
									headerText="Numero">
									<h:commandLink value="#{empenho.numero}" onclick="dlgEmp.hide()"
										id="empenho">
										<f:setPropertyActionListener
											target="#{empenhoBean.empenho}" value="#{empenho}" />
									</h:commandLink>
								</p:column>
								
								<p:column headerText="Interessado">
									<h:outputText value="#{empenho.interessado}" />
								</p:column>
			
									
							</p:dataTable>
						</p:outputPanel>

					</h:form>
				</p:dialog>
				
		</div>


	</ui:define>
</ui:composition>
</html>